/**
**************************************************************************************
*Founder Effect                                                                      *
*Copyright (C) 2006-2007, 5d Studios (www.5d-Studios.com)                            *
*                                                                                    *
*This library is free software; you can redistribute it and/or                       *
*modify it under the terms of the GNU Lesser General Public                          *
*License as published by the Free Software Foundation; either                        *
*version 2.1 of the License, or (at your option) any later version.                  *
*                                                                                    *
*This library is distributed in the hope that it will be useful,                     *
*but WITHOUT ANY WARRANTY; without even the implied warranty of                      *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                   *
*Lesser General Public License for more details.                                     *
*                                                                                    *
*You should have received a copy of the GNU Lesser General Public                    *
*License along with this library; if not, write to the Free Software                 *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA      *
**************************************************************************************
*/
#pragma once

#include "../shared/color.h"
#include "../Commands.h"

/**
==========================
Lightning Type
==========================
*/
enum eLightningType
{
    LT_SMALL = 7,
    LT_MED = 8,
    LT_BIG = 31,
    LT_NOTHING = 0
};

/** Rain command */
class Weather;
class Rain_f : public ICommand
{
public:
    Rain_f() { m_weather = NULL; };
    void Exec(std::string &s);
    void Set(Weather* w) { m_weather = w; };

    ~Rain_f() {};
private:
    Weather* m_weather;
};
class RainTime_f : public ICommand
{
public:
    RainTime_f() { m_weather = NULL; };
    void Exec(std::string &s);
    void Set(Weather* w) { m_weather = w; };

    ~RainTime_f() {};
private:
    Weather* m_weather;
};


/**
=========================
Handles weather effects
such as rain, snow, nightfall,
and daylight
=========================
*/
class Weather
{
public:
    Weather(void);

    /** Get the Time of day in hours */
    float GetTimeOfDay();
    void  SetNextDayTime(float d) { m_nextDayTime = d; };

    /** Set Rain */
    void EnableRain(bool b) { m_rain = b; };
    /** Check Raining */
    bool IsRaining() { return m_rain; };
    /** Check Lightning */
    int CheckLightning();

    /** Enable fog */
    void EnableFog(bool b) { m_fog = b; };
    /** check fog */
    bool IsFogEnabled() { return m_fog; };
    /** Set fog color */
    void SetFogColor( int r, int g, int b, int a=1);
    /** Get fog color */
    Color GetFogColor() { return m_fColor; };
private:
    // rain
    bool    m_rain;
    // fog 
    bool    m_fog;
    // fog color
    Color   m_fColor;

    // old time
    float   m_nextDayTime;
    // am to pm
    bool    m_lap;

    // next possible lightining
    float   m_nextLightning;
    int     m_type;

    // console command for toggling rain
    Rain_f      rain_f;
    RainTime_f  rainTime_f;

public:
    virtual ~Weather(void);
};
